package com.example.demo1.controller.requests;

import com.example.demo1.model.Category;
import com.example.demo1.model.Drink;
import com.example.demo1.service.ICategoryService;
import com.example.demo1.service.IDrinkService;
import lombok.Builder;
import org.joda.money.CurrencyUnit;
import org.joda.money.Money;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class RouterController {
    @Autowired
    public IDrinkService drinkService;
    @GetMapping("/")
    public String Index(){
        return "manage/login";
    }
    @GetMapping("/manage/index")
    public String adminIndex(){
        return "manage/index";
    }
    @GetMapping("/manage/welcome")
    public String welcome(){
        return "manage/welcome";
    }
    @GetMapping("/menu/drink")
    public String drinkIndex(){
        return "/drink/index";
    }
    @GetMapping("/drink/addform")
    public String drinkAddform(){
        return "/drink/add";
    }
    @GetMapping("/drink/updateform")
    public ModelAndView drinkUpdateForm(@RequestParam Integer id){
        ModelAndView mv = new ModelAndView("/drink/edit");
        Drink build = drinkService.getDrinkById(id);
        mv.addObject("data",build);
        return mv;
    }
//-------------------------------------------------------------------------------------------------------------------
    @Autowired
    public ICategoryService categoryService;

    @GetMapping("/menu/category")
    public String categoryIndex(){
        return "category/index";
    }
    @GetMapping("/category/addform")
    public String categoryAddform(){
        return "/category/add";
    }
    @GetMapping("/category/updateform")
    public ModelAndView categoryUpdateForm(@RequestParam Integer id){
        ModelAndView mv1 = new ModelAndView("/category/edit");
        Category buile1 = categoryService.getCategoryById(id);
        mv1.addObject("data",buile1);
        return mv1;
    }


}
